package com.elong.businesstravel.protocol.order;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.text.TextUtils;

import com.elong.businesstravel.entitys.SubmitOrderParam;
import com.elong.businesstravel.include.Version;
import com.elong.businesstravel.protocol.ProtocolDef;
import com.elong.businesstravel.protocol.baserequest.BaseELongHttpRequest;

/**
 * 创建订单
 * 
 * @author lenovo
 * 
 */
public class CreateOrderRequest extends BaseELongHttpRequest {
	
	public CreateOrderRequest(Context context
			, String hotelid
			, String roomid
			, String rpid
			, String hotelname
			, String roomname
			, String ratename
			, String starttime
			, String endtime
			, String roomnum
			, String customertype
			, String paymenttype
			, String totalprice
			, String startdate
			, String enddate
			, String earlyarrival
			, String latestarrival
			, String customer
			, String mobile
			, String needcreditcard
			, String crednum
			, String cvv
			, String expyear
			, String expmonth
			, String holdername
			, String idtype
			, String idno
			, String needinvoice
			, String invoicetitle
			, String invoicetype
			, String province
			, String city
			, String area
			, String invoiceaddress
			, String invoicename
			, String invoicemobile
			, String userscore
			, String bouns
			, String totalbouns
			, String paymentmothd //对应payment
															// Paymentproviderid参数
			, String paymentmothds //对应payment PaymentMethod参数
			, String guaranteeType //array("0","1","2"),'mast'
															// => 'N'),//担保方式 0无担保 1 T点之后担保
															// 2全天担保
			, String ticketid
			, String ticketcash
			) {
		super(context);

		JSONObject jsonObject = new JSONObject();
		try {
			//红包
			if(TextUtils.isEmpty(ticketid)){
				jsonObject.put("ticketid", "0");
			}else {
				jsonObject.put("ticketid", ticketid);
			}
			if(TextUtils.isEmpty(ticketcash)){
				jsonObject.put("ticketcash", "0");
			}else {
				jsonObject.put("ticketcash", ticketcash);
			}
			
			jsonObject.put("hotelid", hotelid);
			jsonObject.put("roomid", roomid);
//			jsonObject.put("roomid", "0004");
			jsonObject.put("rpid", rpid);
			//
			jsonObject.put("hotelname", hotelname);
			jsonObject.put("roomname", roomname);
			jsonObject.put("ratename", ratename);
			//
			if(!"".equals(starttime))
			jsonObject.put("starttime", starttime);// N
			if(!"".equals(endtime))
			jsonObject.put("endtime", endtime);// N
			//
			if(!"".equals(roomnum))
			jsonObject.put("roomnum", roomnum);
			if(!"".equals(customertype))
			jsonObject.put("customertype", customertype);
			if(!"".equals(paymenttype))
			jsonObject.put("paymenttype", paymenttype);// ("Prepay","Selfpay")),
			if(!"".equals(totalprice))
			jsonObject.put("totalprice", totalprice);
			if(!"".equals(startdate))
			jsonObject.put("startdate", startdate);
			if(!"".equals(enddate))
			jsonObject.put("enddate", enddate);
			//
			if(!"".equals(earlyarrival))
			jsonObject.put("earlyarrival", earlyarrival);// N
			jsonObject.put("latestarrival", latestarrival);
			jsonObject.put("customer", customer);
			jsonObject.put("mobile", mobile);
			//
			if(!"".equals(needcreditcard))
			jsonObject.put("needcreditcard", needcreditcard);// ("0","1"),'mast' => 'N'),
			if(!"".equals(crednum))
			jsonObject.put("crednum", crednum);// N
			if(!"".equals(cvv))
			jsonObject.put("cvv", cvv);// N
			if(!"".equals(expyear))
			jsonObject.put("expyear", expyear);// N
			if(!"".equals(expmonth))
			jsonObject.put("expmonth", expmonth);// N
			if(!"".equals(holdername))
			jsonObject.put("holdername", holdername);// N
			if(!"".equals(idtype))
			jsonObject.put("idtype", idtype);// N
			if(!"".equals(idno))
			jsonObject.put("idno", idno);// N
			//
			if(!"".equals(needinvoice))
			jsonObject.put("needinvoice", needinvoice);// N array("0","1"),'mast' =>
												// 'N'),
			if(!"".equals(invoicetitle))
			jsonObject.put("invoicetitle", invoicetitle);// N
			if(!"".equals(invoicetype))
			jsonObject.put("invoicetype", invoicetype);// N
			if(!"".equals(province))
			jsonObject.put("province", province);// N
			if(!"".equals(city))
			jsonObject.put("city", city);// N
			if(!"".equals(area))
			jsonObject.put("area", area);// N
			if(!"".equals(invoiceaddress))
			jsonObject.put("invoiceaddress", invoiceaddress);// N
			if(!"".equals(invoicename))
			jsonObject.put("invoicename", invoicename);// N
			if(!"".equals(invoicemobile))
			jsonObject.put("invoicemobile", invoicemobile);// N
			//
			//
			if(!"".equals(userscore))
			jsonObject.put("userscore", userscore);// N
			if(!"".equals(bouns))
			jsonObject.put("bouns", bouns);// N
			if(!"".equals(totalbouns))
			jsonObject.put("totalbouns", totalbouns);// N
			//
			if(!"".equals(paymentmothd))
			jsonObject.put("paymentmothd", paymentmothd);// N //对应payment
												// Paymentproviderid参数
			if(!"".equals(paymentmothds))
			jsonObject.put("paymentmothds", paymentmothds);// N //对应payment PaymentMethod参数
			//
			if(!"".equals(guaranteeType))
			jsonObject.put("guaranteeType", guaranteeType);// N array("0","1","2"),'mast'
												// => 'N'),//担保方式 0无担保 1 T点之后担保
												// 2全天担保
			
		} catch (JSONException e) {
			e.printStackTrace();
		}

		setRequestActionParam(ProtocolDef.ACTION_Createorder, jsonObject);
	}
	
	public CreateOrderRequest(Context context ,SubmitOrderParam submitOrderParam ) {
		super(context);

		JSONObject jsonObject = new JSONObject();
		try {
			//红包
			jsonObject.put("ticketid", submitOrderParam.ticketid);
			jsonObject.put("ticketcash", submitOrderParam.ticketcash);
			
			jsonObject.put("hotelid", submitOrderParam.hotelid);
			jsonObject.put("roomid", submitOrderParam.roomid);
			jsonObject.put("rpid", submitOrderParam.rpid);
			jsonObject.put("hotelname", submitOrderParam.hotelname);
			jsonObject.put("roomname", submitOrderParam.roomname);
			jsonObject.put("ratename", submitOrderParam.ratename);
			//
			if(!"".equals(submitOrderParam.starttime))
			jsonObject.put("starttime", submitOrderParam.starttime);// N
			if(!"".equals(submitOrderParam.endtime))
			jsonObject.put("endtime", submitOrderParam.endtime);// N
			//
			if(!"".equals(submitOrderParam.roomnum))
			jsonObject.put("roomnum", submitOrderParam.roomnum);
			if(!"".equals(submitOrderParam.customertype))
			jsonObject.put("customertype", submitOrderParam.customertype);
			if(!"".equals(submitOrderParam.paymenttype))
			jsonObject.put("paymenttype", submitOrderParam.paymenttype);// ("Prepay","Selfpay")),
			if(!"".equals(submitOrderParam.totalprice))
			jsonObject.put("totalprice", submitOrderParam.totalprice);
			if(!"".equals(submitOrderParam.startdate))
			jsonObject.put("startdate", submitOrderParam.startdate);
			if(!"".equals(submitOrderParam.enddate))
			jsonObject.put("enddate", submitOrderParam.enddate);
			//
			if(!"".equals(submitOrderParam.earlyarrival))
			jsonObject.put("earlyarrival", submitOrderParam.earlyarrival);// N
			jsonObject.put("latestarrival", submitOrderParam.latestarrival);
			jsonObject.put("customer", submitOrderParam.customer);
			jsonObject.put("mobile", submitOrderParam.mobile);
			//
			if(!"".equals(submitOrderParam.needcreditcard))
			jsonObject.put("needcreditcard", submitOrderParam.needcreditcard);// ("0","1"),'mast' => 'N'),
			if(!"".equals(submitOrderParam.crednum))
			jsonObject.put("crednum", submitOrderParam.crednum);// N
			if(!"".equals(submitOrderParam.cvv))
			jsonObject.put("cvv", submitOrderParam.cvv);// N
			if(!"".equals(submitOrderParam.expyear))
			jsonObject.put("expyear", submitOrderParam.expyear);// N
			if(!"".equals(submitOrderParam.expmonth))
			jsonObject.put("expmonth", submitOrderParam.expmonth);// N
			if(!"".equals(submitOrderParam.holdername))
			jsonObject.put("holdername", submitOrderParam.holdername);// N
			if(!"".equals(submitOrderParam.idtype))
			jsonObject.put("idtype", submitOrderParam.idtype);// N
			if(!"".equals(submitOrderParam.idno))
			jsonObject.put("idno", submitOrderParam.idno);// N
			//
			if(!"".equals(submitOrderParam.needinvoice))
			jsonObject.put("needinvoice", submitOrderParam.needinvoice);// N array("0","1"),'mast' =>
												// 'N'),
			if(!"".equals(submitOrderParam.invoicetitle))
			jsonObject.put("invoicetitle", submitOrderParam.invoicetitle);// N
			if(!"".equals(submitOrderParam.invoicetype))
			jsonObject.put("invoicetype", submitOrderParam.invoicetype);// N
			if(!"".equals(submitOrderParam.province))
			jsonObject.put("province", submitOrderParam.province);// N
			if(!"".equals(submitOrderParam.city))
			jsonObject.put("city", submitOrderParam.city);// N
			if(!"".equals(submitOrderParam.area))
			jsonObject.put("area", submitOrderParam.area);// N
			if(!"".equals(submitOrderParam.invoiceaddress))
			jsonObject.put("invoiceaddress", submitOrderParam.invoiceaddress);// N
			if(!"".equals(submitOrderParam.invoicename))
			jsonObject.put("invoicename", submitOrderParam.invoicename);// N
			if(!"".equals(submitOrderParam.invoicemobile))
			jsonObject.put("invoicemobile", submitOrderParam.invoicemobile);// N
			//
			//
			if(!"".equals(submitOrderParam.userscore))
			jsonObject.put("userscore", submitOrderParam.userscore);// N
			if(!"".equals(submitOrderParam.bouns))
			jsonObject.put("bouns", submitOrderParam.bouns);// N
			if(!"".equals(submitOrderParam.totalbouns))
			jsonObject.put("totalbouns", submitOrderParam.totalbouns);// N
			//
			if(!"".equals(submitOrderParam.paymentmothd))
			jsonObject.put("paymentmothd", submitOrderParam.paymentmothd);// N //对应payment
												// Paymentproviderid参数
			if(!"".equals(submitOrderParam.paymentmothds))
			jsonObject.put("paymentmothds", submitOrderParam.paymentmothds);// N //对应payment PaymentMethod参数
			//
			if(!"".equals(submitOrderParam.guaranteeType))
			jsonObject.put("guaranteeType", submitOrderParam.guaranteeType);// N array("0","1","2"),'mast'
												// => 'N'),//担保方式 0无担保 1 T点之后担保
												// 2全天担保
			
		} catch (JSONException e) {
			e.printStackTrace();
		}

		setRequestActionParam(ProtocolDef.ACTION_Createorder, jsonObject);
	}

}
